<!DOCTYPE html>
<html lang="en-us" id="extr-page">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../global/css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
    <link rel="stylesheet" href="../../global/css/ztree/demo.css" type="text/css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <form class="form-horizontal" onsubmit="return false" id="form" enctype="multipart/form-data">
        <fieldset>
            <input type="hidden" id="id" name="id">
            <!--隐藏域获取后台传递过来的值-->
            <input type="hidden" name="sprovince" id="sprovince">
            <!--隐藏域获取后台传递过来的值-->
            <input type="hidden" name="scity" id="scity">
            <!--隐藏域获取后台传递过来的值-->
            <input type="hidden" name="scounty" id="scounty">
            <div class="form-group">
                <label class="col-md-2 control-label">名称</label>
                <div class="col-md-10">
                    <input class="form-control" placeholder="名称" type="text" name="name" id="name"
                           data-bv-notempty="true"
                           data-bv-notempty-message="名称 不能为空">
                </div>
            </div>
             <div class="form-group">
                                      <label class="col-md-2 control-label">省:</label>
                                      <div class="col-md-10" style="width: 120px">
                                       <select class="form-control input-sm" name="s_province" id="s_province">
                                       </select>
                                  </div>
                                  </div>
              <div class="form-group">
                                       <label class="col-md-2 control-label">市:</label>
                                       <div class="col-md-10" style="width: 120px">
                                        <select class="form-control input-sm" name="s_city" id="s_city">
                                         </select>
                                   </div>
                                   </div>
               <div class="form-group">
                                        <label class="col-md-2 control-label">县/区:</label>
                                        <div class="col-md-10" style="width: 120px">
                                        <select class="form-control input-sm" name="s_county" id="s_county">
                                        </select>
                                    </div>
                                    </div>
            <div class="form-actions">
                <div class="row" align="center">
                    <div class="col-md-12">
                        <button class="btn btn-primary" onclick="location.href='tradList.html'">返回</button>
                        <button class="btn btn-primary" type="submit" onclick="add()">
                            <i class="fa fa-save"></i> 保存
                        </button>
                    </div>
                </div>
            </div>

        </fieldset>
    </form>
</div>

<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../global/js/common.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/libs/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="../../global/js/my/ztree-menu.js"></script>
<script type="text/javascript" src="../../global/js/area.js"></script>
<script type="text/javascript" src="../../global/js/ajaxfileupload.js"></script>
<script type="text/javascript">
_init_area();
    layui.use('layer', function () {
        var layer = layui.layer;
    });

    initData();

    function initData() {
        var id = getUrlParam("id");
        if (id != "") {
            $.ajax({
                type: 'get',
                url: '/clyjTradingArea/' + id,
                async: false,
                success: function (result) {
                    var data = result.data;
                    $("#id").val(data.id);
                    $("#name").val(data.name);
                    $("#sprovince").val(data.sprovince);
                    $("#scity").val(data.scity);
                    $("#scounty").val(data.scounty);
                    var province = $("#sprovince").val();
                    var city = $("#scity").val();
                    var county = $("#scounty").val();
                    $("#s_province").append("<option selected>"+province+"</option>");
                    $("#s_city").append("<option selected>"+city+"</option>");
                    $("#s_county").append("<option selected>"+county+"</option>");
                }
            });

        }
    }
    $('#form').bootstrapValidator();

    function add() {
        var bootstrapValidator = $("#form").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (!bootstrapValidator.isValid()) {
            return;
        }
$("form").ajaxSubmit({
                type: 'post',
                url: '/clyjTradingArea/saveTrad',
                traditional: true,
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    layer.msg("修改成功", {shift: -1, time: 1000}, function () {
                        location.href = "tradList.html";
                    });
                }
            });
        }
</script>
</body>
</html>